package net.lulihu.pangolin.headless.common.protocol.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import net.lulihu.pangolin.headless.common.protocol.ProtocolMessage;

/**
 * 消息处理
 */
public class MessageHandler extends SimpleChannelInboundHandler<ProtocolMessage> {

    @Override
    protected final void channelRead0(ChannelHandlerContext ctx, ProtocolMessage msg) throws Exception {
        MessageTypeHandler handler = MessageTypeHandlerRegistration.getTypeHandler(msg.getType());
        handler.handle(ctx, msg);
    }

}
